package loja.thinlet;

import java.io.IOException;
import java.util.LinkedList;

import loja.Produto;

import thinlet.Thinlet;

public class WProduto {

	Thinlet thinlet;

	public WProduto(Thinlet thinlet) {

		this.thinlet = thinlet;

	}

	public void listar(Object table, LinkedList<Produto> produtos)
			throws IOException {

		Object row;
		Object cell;
		
		for (Produto p : produtos) {
			row = Thinlet.create("row");
			cell = Thinlet.create("cell");
			thinlet.setString(cell, "text", p.getCodigo());
			thinlet.add(row, cell);

			cell = Thinlet.create("cell");
			thinlet.setString(cell, "text", p.getNome());
			thinlet.add(row, cell);

			cell = Thinlet.create("cell");
			thinlet.setString(cell, "text", p.getUnidade());
			thinlet.add(row, cell);

			cell = Thinlet.create("cell");
			thinlet.setString(cell, "text", Double.toString(p.getPreco_venda()));
			thinlet.add(row, cell);

			thinlet.add(table, row);
		}
		


	}

}
